package com.kotlin.demo

import kotlin.math.roundToInt

const val info = "I'm zq"

fun main() {
    val indexOf = info.indexOf('m')
    print(info.substring(0, indexOf))
    println(info.substring(0 until indexOf))  // kotlin 一般采用这种写法


    //split 操作
    val jsonText = "happy,sadness,insipid,except"
    val result = jsonText.split(",")
    println(result)

    val (v1,v2,v3,v4) = result
    println("v1:$v1 v2:$v2 v3:$v3 v4:$v4")

    //数据类型转换
    val num = 65.3249723
    val num2 = 65.749723
    val num3 = 65.74
    println(num.toInt())
    println(num.roundToInt())
    println(num2.roundToInt())

    println("%.3f".format(num3))


}